import 'package:flutter/material.dart';
import 'package:flutter2/dialog/dialog_common.dart';
import 'package:flutter2/ui/login.dart';
import 'package:flutter2/utils/sp.dart';
import 'package:flutter2/widget/base/normal_button.dart';
import 'package:flutter2/widget/title_bar.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

class SettingPage extends StatelessWidget {
  const SettingPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: TitleBar.buildAppBar(
        title: "设置",
      ),
      body: Container(
        width: double.infinity,
        padding: EdgeInsets.symmetric(vertical: 20),
        child: Column(
          children: [
            NormalButton(
              text: "Cerrar session",
              click: () {
                SmartDialog.show(
                  clickMaskDismiss: false,
                  animationType: SmartAnimationType.fade,
                  builder: (context) {
                    return DialogCommon(
                      title: "Sugerencia",
                      content: "¿Confirmar cierre de sesión?",
                      leftText: "Confirmar",
                      rightText: "Cancelar",
                      leftClick: () {
                        SmartDialog.dismiss();
                        SPUtil.putObject("user", {});
                        Get.offAll(LoginPage());
                      },
                      rightClick: SmartDialog.dismiss,
                    );
                  },
                );
              },
            )
          ],
        ),
      ),
    );
  }
}
